const express=require("express")
const router=express.Router();
const pool=require("../pool");


//查询商品是否添加购物车
router.get("/",(req,res)=>{
  //1:获取参数
  var did=parseInt(req.query.did);    //商品id
  //var uid=parseInt(req.query.uid);    //获取用户id
  var id=req.session.uid
  //console.log(id);
  //2:sql select
  var sql=`SELECT id FROM yhc_cart WHERE did=? AND uid=?`;
  pool.query(sql,[did,id],(err,result)=>{
    if(err) throw err;
    if(result.length>0){//如果收藏数据库没有数据插
      res.send({code:2})  //当code为2时表示已经收藏成功
    }
  })
})
module.exports=router;